package com.buaa.controller;

import com.buaa.common.Result;
import com.buaa.dto.TrafficIncidentDTO;
import com.buaa.service.impl.TrafficIncidentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/policecase")
public class PoliceCaseController {
    @Autowired
    private TrafficIncidentServiceImpl trafficIncidentService;


    @PutMapping
    public Result update(@RequestBody TrafficIncidentDTO dto, HttpServletRequest request){
        return trafficIncidentService.updateTrafficIncident(dto, request);
    }
    @DeleteMapping("{id}")
    public Result deleteById(@PathVariable("id") Integer id, HttpServletRequest request){
        return trafficIncidentService.deleteByTrafficIncidentId(id, request);
    }

    @PostMapping("/add")
    public Result add(@RequestBody TrafficIncidentDTO dto, HttpServletRequest request) {
        return trafficIncidentService.saveTrafficIncident(dto, request);
    }

//    // 翻页/*/
    @GetMapping("/page")
    public Map<String, Object> findPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize) {

        return trafficIncidentService.findPage(pageNum, pageSize);
    }
}
